<?php
    /*
	 * My database class
	 */
	 
	 class database
	 {
	 	private $link, $database;
		private $user		= "unn_v015097";
		private $pass		= "wa8c8979x7z37";
		private $db			= "unn_v015097";
		private $host		= "localhost";
		
		public function __construct()
		{
			$this->link	= mysql_connect($this->host, $this->user, $this->pass, true);
			if(!$this->link)
			{
				echo "Couldn't connect to MySQL server, error: " . mysql_error();
			}
			else
			{
				//select db
				$this->database	= mysql_select_db($this->db, $this->link);
				if(!$this->database)
				{
					echo "Couldn't select database: " . $this->db . ". Error: " . mysql_error();
				}
			}
		}
		
		public function __destruct()
		{
			if($this->link)
			{
				mysql_close($this->link);
			}
		}
		
		public function getQuery($sql)
		{
			return mysql_query($sql, $this->link);
		}
		
		public function getResult($sql)
		{
			$query	= $this->getQuery($sql);
			$result	= array();
			$i 		= 0;
			while($row = mysql_fetch_array($query))
			{
				array_push($result, $row);
			}
			return $result;
		}
	 }
?>